<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch">

      <!--请输入标准数据集ID-->
      <el-form-item prop="standardId">
        <el-input v-model="queryParams.standardId" placeholder="Pls input Standard ID" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <!--根据分析结果状态检索-->
      <el-form-item prop="llmLabResultStatus">
        <el-select v-model="queryParams.status" placeholder="Select Status" clearable>
          <el-option v-for="dict in dict.type.llm_lab_result_status" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <!--根据比对等级选择-->
      <el-form-item prop="adeMatchLevel">
        <el-select v-model="queryParams.matchLevel" placeholder="Select Ade Match Level" clearable>
          <el-option v-for="dict in dict.type.ade_match_level" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">Search</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">Rest</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="llmlabresultList">
      <el-table-column label="LLM Lab ID" width="90" align="center" prop="llmTaskId" />
      <el-table-column label="Standard ID" width="90" align="center" prop="standardId">
        <template slot-scope="scope">
          <el-button type="text" @click="handleStandardDetail(scope.row)">
            {{ scope.row.standardId }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="Ades" align="left" prop="ades" show-overflow-tooltip />
      <el-table-column label="Level" width="120" align="center" prop="matchLevel">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.ade_match_level" :value="scope.row.matchLevel" />
        </template>
      </el-table-column>
      <el-table-column label="Status" width="70" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.llm_lab_result_status" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="Knowledges" width="100" align="center" prop="knowledgeCount" />
      <el-table-column label="SimScore" width="100" align="center" prop="avgSimscore" />
      <el-table-column label="Duration(Sec)" width="100" align="center" prop="timeConsumed" />
      <el-table-column label="Remark" width="200" align="center" prop="remark" show-overflow-tooltip />
      <el-table-column label="Create Time" width="140" align="center" prop="createTime" />
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />



    <el-dialog :visible.sync="showStandardDialog" @close="selectedId = null" width="80%" :title="'Standard Detail'">
      <standard-detail-dialog v-if="selectedId" :id="selectedId" />
    </el-dialog>

  </div>
</template>

<script>
import { listLlmlabresult, getLlmlabresult, delLlmlabresult, addLlmlabresult, updateLlmlabresult } from "@/api/ade/llmlabresult";

import StandardDetailDialog from "@/views/ade/standard/detail.vue";

export default {
  name: "Llmlabresult",
  dicts: ["llm_lab_result_status", "ade_match_level"],
  components: {
    StandardDetailDialog,
  },
  props: {
    id: {                //ADE LLM Lab ID
      type: Number,
      required: true
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // Ade LLM Lab Result表格数据
      llmlabresultList: [],

      showStandardDialog: false,
      selectedId: null,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 12,
        llmTaskId: null,
        standardId: null,
        ades: null,
        status: null,
        matchLevel: null,
      },
    };
  },
  created() {
    this.queryParams.llmTaskId = this.id; // 使用传入的llmLabId
    this.getList();
  },
  watch: {
    '$route'(to, from) {
      if (to.path === '/analysis/llmlabresult') {
        this.queryParams.llmTaskId = this.$route.query.llmLabId || null;
        if (this.queryParams.llmTaskId) {
          this.showSearch = false; // 如果有llmLabId参数，则隐藏搜索条件
        }
        this.getList();
      }
    }
  },
  methods: {

    //打开标准数据集详情页面
    handleStandardDetail(row) {
      this.selectedId = row.standardId;
      this.showStandardDialog = true;
    },

    /** 查询Ade LLM Lab Result列表 */
    getList() {
      this.loading = true;
      listLlmlabresult(this.queryParams).then(response => {
        this.llmlabresultList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        llmTaskId: null,
        standardId: null,
        ades: null,
        remark: null,
        timeConsumed: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
